<template>
	<view class="">
		<!-- 个人中心 -->
		<view v-show="pagee" class="">
			<view>
				<u-navbar title="个人中心" :autoBack="true" @leftClick="leftClick">
				</u-navbar>
			</view>
			<view class="phtot" style="margin-top: 100px; ">
				<view v-if="userr!=''" class="" style="margin-left: 45%; margin-top: 60px;">
					<view v-for="(item,index ) in list" :key="index">
						<u-avatar :src=item.headPortrait shape="circle"></u-avatar>
					</view>
				</view>

				<view v-else class="" style=" margin-top: 60px; ">
					<view class="" style="margin-left: 43%;">
						<u-avatar :src=src shape="circle"></u-avatar>
					</view>
					<view @click="login" style="width: 20%; margin: 0% auto;margin-top: 20px; ">
						<u-button text="去登录"></u-button>
					</view>

				</view>
			</view>

			<view class="" style="margin-top: 10px;">
				<u-cell-group>
					<u-cell @click="order" icon="order" title="我的订单"></u-cell>
					<u-cell @click="qianbao" icon="rmb-circle" title="钱包"></u-cell>
					<u-cell @click="coupons" icon="red-packet" title="优惠卡卷"></u-cell>
					<u-cell @click="centen" icon="man-add" title="个人信息"></u-cell>
					<u-cell @click="chat" icon="man-add" title="客服中心"></u-cell>
					<u-cell @click="comments" icon="chat" title="我的评论"></u-cell>
					<u-cell @click="complaint" icon="info" title="我的投诉"></u-cell>
					<u-cell @click="upname" icon="edit-pen" title="修改昵称"></u-cell>
				</u-cell-group>
			</view>
			<view class="">
				<u-popup :show="showname" mode="center" @close="closeee" @open="open" closeable="ture">
					<view style="width: 300px; height: 110px; margin-top: 10px;">
						<view class="" style="width: 80%;margin-left: 8%; ">
							<u--input placeholder="请输入要修改的昵称" border="surround" v-model="name" clearable></u--input>
						</view>
						<view class="" style="width: 30%; margin-left: 35%; margin-top: 20px;">
							<u-button @click="upusername" type="primary" text="确定"></u-button>
						</view>
					</view>
				</u-popup>
			</view>
		</view>
		<!--我的投诉  -->
		<view class="" v-show="complaintttt">
			<view>
				<u-navbar title="我的投诉" :autoBack="true" @leftClick="leftClick">
				</u-navbar>
			</view>
			<view class="" style="margin-top: 80px;">

			</view>

			<view class="u-page" v-for="(item,index) in totos" :key="index">
				<view class="" style="display: flex; height: 50px;  margin-top: 20px;">
					<view class="" style="margin-left: 10px;">
						<u-avatar :src=item.driverPhoto shape="circle"></u-avatar>
					</view>
					<view class="" style="line-height: 30px; margin-left: 10px;">
						{{item.driverName}}
					</view>
					<view class="" style="line-height: 30px; margin-left: 10px; font-size: 13px;">
						{{item.time}}
					</view>
				</view>

				<view class="" style="height: 60px;  ">
					<view class="" style="margin-left: 20px;">
						{{item.content}}
					</view>
				</view>
				<view class="" style="display: flex; margin-top: 10px;border: 1px solid whitesmoke;">
					<view class="" style="width: 20%;">
						<view class="" style="margin-left: 20px;">
							<u-icon name="star" size="20"></u-icon>
						</view>

					</view>
					<view class="" style="width: 25%;">
						<view class="" style="margin-left: 20px;">
							<u-icon name="chat" size="20"></u-icon>
						</view>

					</view>
					<view class="" style="width: 25%;">
						<view class="" style="margin-left: 20px;">
							<u-icon name="thumb-up" size="20"></u-icon>
						</view>

					</view>
					<view class="" style="width: 30%;">
						<view class="" style="margin-left: 20px;">
							<u-icon name="heart" size="20"></u-icon>
						</view>

					</view>
				</view>


			</view>

		</view>
		<!-- 钱包 -->
		<view class="">
			<view v-show="qian" class="qian">
				<view>
					<u-navbar title="我的钱包" :autoBack="true" @leftClick="leftClick">
					</u-navbar>
				</view>
				<view class="">
					<view class="" style="margin-top: 80px; width: 15%; height: 20%; margin-left: 80%;">
						<u-button @click="water" text="钱包流水"></u-button>
					</view>

					<view class="aa"></view>

				</view>
				<view class="bb">

					<view v-for="(item,index) in list" :key="index" class="" style="margin-top: 20px;">
						余额：<span style="color: red; font-size: 20px;">{{item.balance}}</span>
					</view>
					<view class=""
						style="border: 1px solid black; border-radius: 10px; width: 30%; margin: 0% auto; height: 30px; margin-top: 30px;">
						<input type="text" v-model="value" placeholder="请输入金额">
					</view>
					<view class="" style=" width: 50%; margin: 0% auto; margin-top: 40px;">
						<u-button @click="recharge" :disabled="disabled" style="width: 20%;" type="primary" text="充值">
						</u-button>

					</view>
				</view>
			</view>
			<!-- 钱包流水 -->
			<view class="" v-show="monetdebt">
				<view>
					<u-navbar title="我的钱包流水" @leftClick="leftClick">
					</u-navbar>
				</view>
				<view class="" style="margin-top: 80px;">
				</view>
				<view style="display: flex;height: 60px;border-bottom: 1px solid black; margin-top: 10px;"
					v-for="(item,index) in laundrylist " :key="index">
					<view class="" style="width:20%;margin-left: 5%;" v-for="(i,id) in list" :key="id">
						<u-avatar :src=i.headPortrait shape="circle"></u-avatar>
					</view>
					<view class="" style="width: 80%;">
						<view class="">零钱充值 <span style="margin-left: 55%;">+{{item.number}}</span></view>
						<view class="" style="margin-top: 10px; font-size: 11px;">{{item.time}} </view>
					</view>
				</view>
			</view>
		</view>
		<!-- 个人信息 -->
		<view v-for="(item,index) in list" :key="index" v-show="gr" class="">
			<view class="">
				<u-navbar title="我的个人信息" :autoBack="true" @leftClick="leftClick">
				</u-navbar>
			</view>
			<view class="" style="margin-top: 100px;">
				<u-cell title="昵称" :isLink="false" :value="item.wxName"></u-cell>
				<u-cell title="手机号" :isLink="false" :value="item.phoneNum"></u-cell>
				<u-cell title="注册时间" :isLink="false" :value="item.establishTime"></u-cell>
				<u-cell title="信誉分" :isLink="false" :value="item.credit"></u-cell>
				<u-cell @click="imggg" title="修改头像" :isLink="true"></u-cell>

				<u-cell @click="updaphone" title="修改手机号" :isLink="true" arrow-direction="right"></u-cell>
				<u-button @click="tuichu" :disabled="disabled" type="primary" text="退出登录"></u-button>
			</view>

			<!-- 修改手机号码 -->
			<view class="content" v-show="upphone">
				<view><input style="padding-left: 10px; color: white;border: 1px solid white;" id="app" type="text"
						v-model="phone" placeholder="请输入原手机号码"></view>
				<view><input style="padding-left: 10px; color: white;border: 1px solid white;" id="app" type="text"
						v-model="xinphone" placeholder="请输入新手机号码"></view>
				<view class="" style="display: flex; margin-top: 10px;">
					<view class="" style="width: 100px; border: 1px solid white;">
						<input style="color: white;" type="text" v-model="yzmvalues" placeholder="请输入验证码">
					</view>
					<view class="" style="width: 50%; margin-left: 1%; line-height: 40px;">
						<u-toast ref="uToast"></u-toast>
						<u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-code>
						<u-button @tap="getCode">{{tips}}</u-button>
					</view>

				</view>
				<view class="" style="display: flex; margin-top: 30px;">
					<button @click="updatephone">点击修改</button>
					<button style="margin-left: 20px;" @click="cancelphone">取消修改</button>
				</view>
			</view>

		</view>
		<!-- 我的订单 -->
		<view v-show="orderr" class="">
			<view>
				<u-navbar title="我的订单" @leftClick="leftClick" :autoBack="true">
				</u-navbar>
			</view>
			<view class="" style="margin-top: 80px;">

			</view>
			<view class="view" v-show="item.state==8 || item.state==9 || item.state==5 || item.state==42"
				v-for="(item,index) in catlist" :key="index">
				<view class="" style="margin-top: 20px;" v-if="item.carType==1">
					<span style="margin-left: 20px;">{{item.creationtime}} | 快车 <span
							style="margin-left: 30px;">{{item.price}}元</span></span>
					<p style="margin-top: 10px; margin-left: 20px;">{{item.departure}}</p>
					<p style="margin-top: 10px; margin-left: 20px;">{{item.destination}}</p>
				</view>
				<view class="" style="margin-top: 20px;" v-else>
					<span style="margin-left: 20px;">{{item.creationtime}} | 出租车 <span
							style="margin-left: 30px;">{{item.price}}元</span></span>
					<p style="margin-top: 10px; margin-left: 20px;">{{item.departure}}</p>
					<p style="margin-top: 10px; margin-left: 20px;">{{item.destination}}</p>
				</view>
				<view class="" style="height: 20px; border-bottom: 1px solid black;">

				</view>
				<view class="" style="margin-top: 10px; display: flex; height: 50px;">
					<view v-if="item.state==42" class="" style="margin-left: 30px; color: #909399;">
						已退款
					</view>
					<view v-if="item.state==8" class="" style="margin-left: 30px; color: #909399;">
						已取消
					</view>
					<view v-if="item.state==9" class="" style="margin-left: 30px; color: #909399;">
						已完成
					</view>
					<view v-if="item.state==5" class="" style="margin-left: 30px; color: #909399;">
						未支付
					</view>
					<view class="" style="margin-left: 40%; width: 20%;" v-if="item.state==5">
						<view class="">
							<u-button type="primary" @click="zifu(item)" text="去支付"></u-button>
						</view>
					</view>
					<view class="" style="margin-left: 20%; width: 20%; display: flex;" v-if="item.state==9">
						<view class="" style="margin-left: 10px;">
							<u-button type="primary" @click="tuikuan(item)" text="退款"></u-button>
						</view>
						<view class="" style="margin-left: 10px;">
							<u-button type="primary" @click="myreview(item)" text="评论"></u-button>
						</view>
						<view class="" style="margin-left: 10px;">
							<u-button type="primary" @click="toshu(item)" text="投诉"></u-button>
						</view>

					</view>
				</view>

				<view class="" style="height: 30px;">

				</view>
			</view>
			<!-- 支付 -->
			<view class="">
				<u-popup :show="zifuqian" mode="center" @close="close" @open="open">
					<view class="" style="height: 190px; width: 300px; background-image: url(../../static/zhuzi.webp);">
						<view class="" style="margin-left: 35%; color: white;">
							你需要支付
						</view>
						<view class="" style="margin-left: 40%; margin-top: 4%; color: yellow;">
							{{zifulist.price}}元
						</view>
						<view class="" style="margin-left: 10%; margin-top: 2%; color: white;">
							{{zifulist.origin}}
						</view>
						<view class="" style="margin-left: 10%; margin-top: 10px; color: white;">
							{{zifulist.bourn}}
						</view>

						<view class="" style="width: 50%; margin-left: 25%; margin-top: 5%;">
							<u-button @click="zhizhifu" :disabled="disabled" type="primary" text="支付"></u-button>
						</view>
					</view>
				</u-popup>
			</view>
			<!-- <u-loadmore :status="status" /> -->
			<!-- 评论 -->
			<view class="pinglunlun" style="display: flex;">
				<u-popup :show="review" mode="center" @close="close" @open="open"
					style="background-image: url(../../static/yun.png)">
					<view class="" style="margin-left: 20px; margin-top: 10px; display: flex;">
						<view style="font-size: 13px;">综合评分</view>
						<view>
							<u-rate :count="count" v-model="xingvalue"></u-rate>
						</view>
					</view>
					<view class="" style="height: 150px; width: 300px; margin-top: 5px;">
						<u--textarea v-model="value2" height=80 placeholder="请输入评论的内容" count></u--textarea>
						<view class="" style="width: 80%; margin: 0% auto; margin-top: 5px;">
							<u-button @click="send" color="red" :disabled="disabled" type="primary" text="发送">
							</u-button>
						</view>

					</view>
				</u-popup>
			</view>
			<!-- 投诉 -->
			<view class="">
				<u-popup :show="complaints" mode="center" @close="close" @open="open">
					<view class="" style="height: 180px; width: 300px; margin-top: 5px;">
						<u--textarea v-model="value2" height=110 placeholder="请输入投诉的内容" count></u--textarea>
						<view class="" style="margin: 0% auto; width: 80%; margin-top: 5px;">
							<u-button @click="dispatch" :disabled="disabled" type="primary" text="发送"></u-button>
						</view>

					</view>
				</u-popup>
			</view>


		</view>
		<!-- 优惠券 -->
		<view class="" v-show="mycoupons">
			<view>
				<u-navbar title="我的优惠券" @leftClick="leftClick" :autoBack="true">
				</u-navbar>
			</view>
			<view class="">
				<view class="" style="margin-top: 80px;"></view>

				<view>
					<view v-if="redlist==''" class="" v-for="(i,index) in redbao" :key="index"
						style="display: flex; border: 1px solid white; border-radius: 8px; background-color:#f3f4f6; height: 120px; width: 90%; margin: 0% auto;"
						class="">
						<view class="" style="width: 35%; margin-top: 10%;">
							<span style="color: orange;  margin-left: 20%;"><span>￥</span><span
									style="font-size: 40px;">{{i.value}}</span></span>
						</view>
						<view class="" style="width: 65%;margin-top: 2%; display: flex;">
							<view class="" style="width: 70%;">
								<p>无门槛优惠券</p>
								<p style="margin-top: 20px; font-size: 12px;">只要叫车就能减{{i.value}}元</p>
								<p style="margin-top: 20px;font-size: 12px;">有效期至2022-12-31</p>
							</view>

							<view class="" style="width: 20%; margin-top: 18%;">
								<u-button @click="receive(i)" type="primary" size="mini" text="领取"></u-button>
							</view>

						</view>
					</view>
					<view v-else-if="redlist!='' && i.state!=31" v-for="(i,id) in redlist" :key="id"
						style="display: flex; border: 1px solid white; border-radius: 8px; background-color:#f3f4f6; height: 120px; width: 90%; margin: 0% auto;"
						class="">
						<view class="" style="width: 35%; margin-top: 10%;">
							<span style="color: orange;  margin-left: 20%;"><span>￥</span><span
									style="font-size: 40px;">{{i.value}}</span></span>
						</view>
						<view class="" style="width: 65%;margin-top: 2%; display: flex;">
							<view class="" style="width: 70%;">
								<p>无门槛优惠券</p>
								<p style="margin-top: 20px; font-size: 12px;">只要叫车就能减{{i.value}}元</p>
								<p style="margin-top: 20px;font-size: 12px;">有效期至{{i.endTime}}</p>
							</view>

							<view class="" style="width: 20%; margin-top: 18%;">
								<u-button v-if="i.state==30" type="primary" size="mini" text="已领取"></u-button>
							</view>

						</view>
					</view>
				</view>


				<view class="">
					<view class="" v-if="discountliat!=''">
						<view class="" v-if="i.stateUser==40" v-for="(i,index) in discountliat" :key="index"
							style="display: flex; border: 1px solid white; border-radius: 8px; background-color:#f3f4f6; height: 120px; width: 90%; margin: 0% auto;">
							<view class="" style="width: 35%; margin-top: 15%;">
								<span style="color: orange;  margin-left: 10%;"><span
										style="font-size: 20px;">{{i.didiCarcoupon}}</span></span>
							</view>
							<view class="" style="width: 65%;margin-top: 2%; display: flex;">
								<view class="" style="width: 70%;">
									<p style="margin-top: 10%;">{{i.didiCarcoupon}}</p>
									<p style="margin-top:20%;font-size: 12px;">{{i.validtime}}</p>
								</view>
								<view class="" style="width: 20%; margin-top: 18%;">
									<u-button v-if="i.stateUser==40" type="primary" size="mini" text="未使用"></u-button>
								</view>

							</view>
						</view>
					</view>
					<view class="" v-else>
					</view>

				</view>

			</view>
		</view>
		<!-- 我的评论 -->
		<view class="" v-show="mycomments">
			<view>
				<u-navbar title="我的评论" @leftClick="leftClick" :autoBack="true">
				</u-navbar>
			</view>
			<view class="" style=" height: 500px;">
				<view class="" style="margin-top: 70px;">

				</view>
				<view class="u-page" v-for="(item,index) in pllist" :key="index"
					style="border: 1px solid #f3f4f6; height: 150px; margin-top: 20px;">
					<view class="" style="display: flex; height: 50px;">
						<view class="" style="margin-left: 10px;">
							<u-avatar :src=item.driverPhoto shape="circle"></u-avatar>
						</view>
						<view class="" style="line-height: 30px; margin-left: 10px;">
							{{item.driverName}}
						</view>
					</view>

					<view class="" style="height: 60px; ">
						<view style="margin-left: 20px; ">
							<view class="">
								<u-rate style="margin-left: 30px;" :count="count" v-model="item.mark"></u-rate>
							</view>
						</view>
						<view class="" style="margin-left: 20px;margin-top: 10px;">
							{{item.commentContent}}
						</view>
					</view>
					<view class="" style="display: flex; margin-top: 10px;border: 1px solid whitesmoke;">
						<view class="" style="width: 20%;">
							<view class="" style="margin-left: 20px;">
								<u-icon name="star" size="20"></u-icon>
							</view>

						</view>
						<view class="" style="width: 25%;">
							<view class="" style="margin-left: 20px;">
								<u-icon name="chat" size="20"></u-icon>
							</view>

						</view>
						<view class="" style="width: 25%;">
							<view class="" style="margin-left: 20px;">
								<u-icon name="thumb-up" size="20"></u-icon>
							</view>

						</view>
						<view class="" style="width: 30%;">
							<view class="" style="margin-left: 20px;">
								<u-icon name="heart" size="20"></u-icon>
							</view>

						</view>
					</view>

				</view>
			</view>

		</view>
		<!-- 修改头像 -->
		<view class="" v-show="upimg">
			<view class="">
				<u-navbar title="修改头像" :autoBack="true" @leftClick="leftClick">
				</u-navbar>
			</view>
			<view class="" style=" margin: 0% auto;margin-top: 80px; margin-left: 29%; ">
				<u-upload width="300rpx" height="300rpx" :fileList="fileList1" @afterRead="afterRead"
					@delete="deletePic" name="1" multiple :maxCount="1" :previewFullImage="true"></u-upload>
			</view>
			<u-button type="primary" @click="imgg" text="确定" customStyle="width:90%;margin-top:10px;"></u-button>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				zifulist: [], //点击支付列表
				zifuqian: false, //支付界面
				DriveruserTable: [],
				yzmvalues: '', //输入的验证码
				tips: '',
				seconds: 60, //验证码时间
				yzm: '', //验证码
				name: '', //修改的名字
				showname: false, //修改名字的弹框
				redlist: [], //红包数据列表
				redbao: [], //红包表
				status: 'loadmore',
				page: 0,
				discountliat: [], //优惠券列表
				monetdebt: false, //钱包账单页面
				laundrylist: [], //钱包流水账单
				b: [],
				a: [],
				totos: [], //投诉表
				complaintttt: false,
				aaaaaaaa: [], //查询缓存id，电话的表
				complaints: false,
				pllist: [],
				matter: [],
				count: 5, //星星总共5个
				xingvalue: 1, //星星的数量
				review: false,
				value2: '',
				catlist: [],
				userid: '', //用户id
				username: '', //身份证名字
				sfznumber: '', //身份证号码
				sfzz: false,
				upimg: false,
				yqian: 5, //优惠券的值
				mycomments: false, //评论页面
				mycoupons: false, //我的优惠券
				seen: false,
				fileList1: [], //图片列表
				disabled: false, //是否禁用按钮
				phone: '', //输入原手机号码的值
				xinphone: '', //输入新手机号码的值
				upphone: false, //修改电话号码的弹框
				uppwd: false, //修改密码的弹框
				useracc: '', //原密码
				acc: '', //输入的原密码
				pwd: '', //密码
				qrpwd: '', //确定密码
				list: [], //个人信息列表
				src: '../../static/didiLogo.jfif', //个人中心图片
				userr: '', //原手机号码
				pagee: true, //个人中心页面
				value: '', //充值钱的值
				qian: false, //钱包页面
				gr: false, //个人信息页面
				orderr: false, //订单页面
				img: '',
				albumWidth: 0,
				usermoney: '' //用户的钱
			}
		},
		methods: {
			//退款
			tuikuan(i) {
				console.log(i, 567)
				let that = this
				uni.showModal({
					title: '提示',
					content: '是否真的要退款',
					success: function(res) {
						if (res.confirm) {
							uni.request({
								url: "http://localhost:8000/refund",
								data: {
									userid: that.userid,
									driverid: i.driverId,
									orderid: i.orderId,
									value: i.price
								},
								method: 'GET',
								success: function(e) {
									console.log(e.data.data, 511)
									uni.showModal({
										title: '退款成功',
										showCancel: false,
									});
									that.topqian()
									console.log(i.driverId, 590)
								},
								fail: function(err) {
									console.log(err)
								},
							})

						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			//支付钱
			zhizhifu() {
				for (let i = 0; i < this.list.length; i++) {
					this.usermoney = this.list[i].balance
				}
				// console.log(this.usermoney,565)
				let that = this
				if (this.usermoney >= this.zifulist.price) {
					uni.request({
						url: "http://localhost:8000/pay",
						data: {
							value: that.zifulist.price,
							user: that.userid
						},
						method: 'GET',
						success: function(e) {
							// console.log(e.data.data,511)
							uni.showModal({
								title: '支付成功',
								showCancel: false,
							});

							//改状态
							uni.request({
								url: "http://localhost:8000/upstate",
								data: {
									user: that.zifulist.orderId
								},
								method: 'GET',
								success: function(e) {
									that.topqian()
								},
								fail: function(err) {
									console.log(err)
								},
							})

							that.zifuqian = false
						},
						fail: function(err) {
							console.log(err)
						},
					})
				} else {
					uni.showModal({
						title: '余额不够得先充钱',
						showCancel: false,
					});
				}

			},
			zifu(i) {
				this.zifuqian = true
				this.zifulist = i
			},
			codeChange(text) {
				this.tips = text;
			},
			getCode() {
				if (this.$refs.uCode.canGetCode) {
					// 模拟向后端请求验证码
					uni.showLoading({
						title: '正在获取验证码'
					})
					setTimeout(() => {
						uni.hideLoading();
						// 这里此提示会被this.start()方法中的提示覆盖
						uni.$u.toast('验证码已发送');
						// 通知验证码组件内部开始倒计时
						this.$refs.uCode.start();
						this.fsyzm()
					}, 2000);
				} else {
					uni.$u.toast('倒计时结束后再发送');
					this.fsyzm()
				}
			},
			end() {
				uni.$u.toast('倒计时结束');
			},
			start() {
				uni.$u.toast('倒计时开始');
			},
			//发送验证码
			fsyzm() {
				console.log(1)
				let that = this
				uni.request({
					url: "http://localhost:8000/yzm",
					data: {
						phone: that.phone
					},
					method: 'GET',
					success: function(e) {
						// console.log(that.phone,510)
						console.log(e.data.data, 511)
						that.yzm = e.data.data
						uni.showModal({
							title: '发送验证码成功',
							showCancel: false,
						});
					},
					fail: function(err) {
						console.log(err)
					},
				})
			},
			//修改名字
			upusername() {
				// console.log(this.name,519)
				let that = this
				if (that.userr != undefined) {
					if (this.name != '' && this.name.length < 9) {
						uni.request({
							url: "http://localhost:8000/upname",
							data: {
								id: that.userid,
								username: that.name
							},
							method: 'GET',
							success: function(e) {
								uni.showModal({
									title: '修改昵称成功',
									showCancel: false,
								});
								that.name = ''
								that.topqian()
								that.showname = false
							},
							fail: function(err) {
								console.log(err)
							},
						})
					} else {
						uni.showModal({
							title: '内容不能为空或者内容不能超9个字',
							showCancel: false,
						});
						this.name = ''
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					});
				}




			},
			open() {},
			closeee() {
				this.showname = false

			},
			//修改名字
			upname() {
				if (this.userr != '') {
					this.showname = true
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					});
				}

			},
			//；懒加载
			// onReachBottom() {
			// 	if(this.page >= 3) return ;
			// 	this.status = 'loading';
			// 	this.page = ++ this.page;
			// 	setTimeout(() => {
			// 		this.catlist += 3;
			// 		if(this.page >= 3) this.status = 'nomore';
			// 		else this.status = 'loading';
			// 	}, 2000)
			// },

			//点击显示钱包流水
			water() {
				this.qian = false
				this.monetdebt = true
			},
			complaint() {
				if (this.userr != '') {
					this.pagee = false
					this.complaintttt = true
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					});
				}

			},
			open() {},
			close() {
				this.complaints = false
				this.review = false
				this.zifuqian = false
			},
			//投诉
			dispatch() {
				this.matter = uni.getStorageSync("toshu")
				if (this.value2 != '') {
					let that = this
					uni.request({
						url: "http://localhost:8000/complain",
						data: {
							user: that.matter.userId,
							drive: that.matter.driverId,
							value: that.value2,
							order: that.matter.orderId
						},
						method: 'GET',
						success: function(e) {
							console.log(e, 999)
							uni.showModal({
								title: '投诉成功',
								showCancel: false,
							});
							that.complaints = false
							that.value2 = ''
							that.topqian()
						},
						fail: function(err) {
							console.log(err)
						},
					})
				} else {
					uni.showModal({
						title: '不能为空',
						showCancel: false,
					});
				}
			},
			toshu(item) {
				this.complaints = true
				uni.setStorageSync("toshu", item)
			},

			myreview(item) {
				this.review = true
				uni.setStorageSync("pinglun", item)
			},
			//评论
			send() {
				this.matter = uni.getStorageSync("pinglun")
				if (this.value2 != '') {
					let that = this
					uni.request({
						url: "http://localhost:8000/matterr",
						data: {
							user: that.matter.userId,
							drive: that.matter.driverId,
							mark: that.xingvalue,
							value: that.value2,
							order: that.matter.orderId
						},
						method: 'GET',
						success: function(e) {
							console.log(e, 999)
							uni.showModal({
								title: '评论成功',
								showCancel: false,
							});
							that.review = false
							that.value2 = ''
							that.topqian()

						},
						fail: function(err) {
							console.log(err)
						},
					})
				} else {
					uni.showModal({
						title: '评论内容不能为空',
						showCancel: false,
					});
				}

			},
			//实名认证
			intoname() {
				console.log(this.username, 308)
				console.log(this.sfznumber, 308)
				const sfzReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
				const name = /^[\u4e00-\u9fa5]+$/
				let that = this
				if (this.username != '' && this.sfznumber != '') {
					if (sfzReg.test(this.sfznumber) && name.test(this.username) && this.username.length >= 2) {
						uni.request({
							url: "http://localhost:8000/intosfz",
							data: {
								user: that.userr,
								name: that.username,
								sfz: that.sfznumber
							},
							method: 'GET',
							success: function(e) {
								that.uppwd = false
								console.log(e.data.data, 999)
								uni.showModal({
									title: '认证成功',
									showCancel: false,
								});
								that.sfznumber = ''
								that.username = ''
								that.topqian()
							},
							fail: function(err) {
								console.log(err)
							},
						})
					} else {
						uni.showModal({
							title: '姓名身份证号码格式错误',
							showCancel: false,
						});
					}
				} else {
					uni.showModal({
						title: '姓名身份证号码不能为空',
						showCancel: false,
					});
				}
			},
			intosfz() {
				if (this.userr != '') {
					this.pagee = false;
					this.sfzz = true
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					});
				}

			},
			//修改图片弹框
			imggg() {
				if (this.userr != '') {
					if (this.upphone == false && this.uppwd == false) {
						this.upimg = true;
						this.gr = false;
						this.pagee = false;
					} else {
						console.log(1)
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					});
				}

			},
			//领取优惠券
			receive(i) {
				let that = this
				uni.request({
					url: "http://localhost:8000/receivee",
					data: {
						user: that.userid,
						value: i.value,
						start: 30
					},
					method: 'GET',
					success: function(e) {
						uni.showModal({
							title: '领取成功',
							showCancel: false,
						});
						that.topqian()
					},
					fail: function(err) {
						console.log(err)
					},
				})
			},
			//显示评论
			comments() {
				console.log(1)
				if (this.userr != '') {
					this.mycomments = true;
					this.pagee = false;
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//显示优惠券
			coupons() {
				if (this.userr != '') {
					this.mycoupons = true;
					this.pagee = false;
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//登录
			login() {
				console.log(1)
				uni.navigateTo({
					url: '/pages/userlogin/userlogin'
				});
			},
			imgg() {
				console.log(this.fileList1, 11111)
				for (var i = 0; i < this.fileList1.length; i++) {
					this.img = this.fileList1[i].url

				}
				if (this.img != '') {
					let that = this
					uni.request({
						url: "http://localhost:8000/upimg",
						data: {
							user: that.userr,
							img: that.img
						},
						method: 'GET',
						success: function(e) {
							uni.showModal({
								title: '修改图片成功',
								showCancel: false,
							});
							that.img = ''
							that.fileList1 = ''
							that.topqian()

						},
						fail: function(err) {
							console.log(err)
						},
					})
				} else {
					uni.showModal({
						title: '修改的图片不能为空',
						showCancel: false,
					});
				}

			},
			// 删除图片
			deletePic(event) {
				this[`fileList${event.name}`].splice(event.index, 1)
			},
			// 新增图片
			async afterRead(event) {
				// 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
				let lists = [].concat(event.file)
				let fileListLen = this[`fileList${event.name}`].length
				lists.map((item) => {
					this[`fileList${event.name}`].push({
						...item,
						status: 'uploading',
					})
				})
			},

			//退出登录
			tuichu() {
				uni.clearStorageSync('userTable');
				uni.clearStorageSync('openid');
				uni.clearStorageSync('toshu');
				uni.clearStorageSync('pinglun');

				uni.navigateTo({
					url: '/pages/userlogin/userlogin'
				});
			},
			//点击显示修改手机号码框
			updaphone() {
				if (this.userr != '') {
					if (this.uppwd == false) {
						this.upphone = true
					} else {
						console.log(1)
					}

				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//取消修改手机号
			cancelphone() {
				this.upphone = false
			},
			//订单个人中心跳转
			order() {
				if (this.userr != '') {
					this.pagee = false;
					this.orderr = true
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//个人中心
			centen() {
				if (this.userr != '') {
					this.pagee = false;
					this.gr = true
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//点击返回个人中心
			leftClick() {
				this.complaintttt = false;
				this.sfzz = false;
				this.mycomments = false;
				this.mycoupons = false;
				this.pagee = true;
				this.gr = false;
				this.orderr = false;
				this.qian = false;
				this.upimg = false;
				this.monetdebt = false;
			},
			//钱包跳转
			qianbao() {
				if (this.userr != '') {
					this.qian = true;
					this.pagee = false;
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			},
			//修改手机号码
			updatephone() {
				const phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
				let that = this
				if (this.yzm != '') {
					if (this.yzm == this.yzmvalues && this.phone != '' && this.phone == this.userr && this.xinphone !=
						'' && phoneReg.test(this.xinphone)) {
						if (this.phone != this.xinphone) {
							uni.request({
								url: "http://localhost:8000/updaphone",
								data: {
									user: that.userr,
									phone: that.xinphone
								},
								method: 'GET',
								success: function(e) {
									console.log(e.data.data, 999)
									uni.showModal({
										title: '修改成功',
										showCancel: false,
									});
									for (var i = 0; i < that.list.length; i++) {
										that.DriveruserTable = {
											userId: that.list[i].userId,
											userTel: that.xinphone,
											headPortrait: that.list[i].headPortrait,
											credit: that.list[i].credit,
											wxName: that.list[i].wxName
										}
										uni.setStorageSync("userTable", that.DriveruserTable)
									}
									if (that.DriveruserTable != '') {
										that.xinphone = ''
										that.upphone = false
									} else {
										console.log(1)
									}
									that.topqian()

								},
								fail: function(err) {
									console.log(err)
								},
							})
						} else {
							uni.showModal({
								title: '修改后的手机号码不能跟原手机号码一样',
								showCancel: false,
							});
							this.xinphone = ''
						}
					} else {
						uni.showModal({
							title: '手机号错误或者新密码格式错误或者验证码错误',
							showCancel: false,
						});
						this.xinphone = ''
					}
				} else {
					uni.showModal({
						title: '验证码不能为空',
						showCancel: false,
					});
					this.xinphone = ''
				}


			},
			uuuser() {
				if (this.userr != '') {
					this.seen = true
				} else {
					this.seen = false
				}
			},
			//查询红包
			chahb() {
				let that = this
				uni.request({
					url: "http://localhost:8000/userreceive",
					data: {},
					method: 'GET',
					success: function(e) {
						// console.log(e.data.data,918918)
						that.redbao = e.data.data
					},
					fail: function(err) {
						console.log(err)
					}
				});
			},
			//获取个人信息
			topqian() {
				this.aaaaaaaa = uni.getStorageSync('userTable')
				this.userr = this.aaaaaaaa.userTel
				let that = this
				uni.request({
					url: "http://localhost:8000/content",
					data: {
						user: that.userr
					},
					method: 'GET',
					success: function(e) {
						that.list = e.data.data
						for (var i = 0; i < that.list.length; i++) {
							that.useracc = that.list[i].userPwd
							that.userid = that.list[i].userId
						}
						uni.request({
							url: "http://localhost:8000/userrrid",
							data: {
								id: that.userid
							},
							method: 'GET',
							success: function(e) {
								that.catlist = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})

						//查评论
						uni.request({
							url: "http://localhost:8000/review",
							data: {
								id: that.userid,
							},
							method: 'GET',
							success: function(e) {
								that.pllist = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})

						// 查投诉
						uni.request({
							url: "http://localhost:8000/complaint",
							data: {
								id: that.userid,
							},
							method: 'GET',
							success: function(e) {
								that.totos = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})


						// 查询钱包流水
						uni.request({
							url: "http://localhost:8000/walletmoney",
							data: {
								id: that.userid
							},
							method: 'GET',
							success: function(e) {
								// console.log(e.data.data,942942)
								that.laundrylist = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})


						// 获取抽奖优惠券
						uni.request({
							url: "http://localhost:8000/discount",
							data: {
								id: that.userid
							},
							method: 'GET',
							success: function(e) {
								// console.log(e.data.data,95895898)
								that.discountliat = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})

						//获取红包的数据
						uni.request({
							url: "http://localhost:8000/cahredbao",
							data: {
								id: that.userid
							},
							method: 'GET',
							success: function(e) {
								that.redlist = e.data.data
							},
							fail: function(err) {
								console.log(err)
							},
						})

					},
					fail: function(err) {
						console.log(err)
					},
				})
			},
			chat() {
				let userChat = {
					userId: '客服',
					UserFace: '',
					userName: '客服',
					chat: '客服'
				}
				uni.setStorageSync('userChat',userChat)
				uni.navigateTo({
					url: "/pages/chat/chat"
				})
			},
			//充钱
			recharge() {
				// console.log(this.value)
				// console.log(this.userr,12346599)
				const intReg = /^[-+]?\d*$/
				if (this.userr != '') {
					if (this.value != '' && intReg.test(this.value) && this.value > 0) {
						if (this.value < 100000) {
							this.disabled = true
							let that = this
							//充钱
							uni.request({
								url: "http://localhost:8000/moneytop",
								data: {
									user: that.userr,
									money: that.value
								},
								method: 'GET',
								success: function(e) {
									that.topqian()
									uni.showModal({
										title: '充值成功',
										showCancel: false,
									});
									that.disabled = false
									that.topqian()


									//插入充钱的数据
									uni.request({
										url: "http://localhost:8000/initmoney",
										data: {
											id: that.userid,
											money: that.value
										},
										method: 'GET',
										success: function(e) {
											console.log(e)
											that.value = ''
										},
										fail: function(err) {
											console.log(err)
										}
									});
								},
								fail: function(err) {
									console.log(err)
								},
							})
						} else {
							uni.showModal({
								title: '充钱不能大于10万',
								showCancel: false,
							});
							this.value = ''
						}

					} else {
						uni.showModal({
							title: '充值钱不能为空或格式不对',
							showCancel: false,
						})
						this.value = ''
					}
				} else {
					uni.showModal({
						title: '请先登录',
						showCancel: false,
					})
				}

			}
		},
		onLoad() {
			//获取个人信息
			this.topqian()
			this.uuuser()
			this.chahb()

		}
	}
</script>

<style lang="scss">
	#app {
		width: 180px;
		border-radius: 6px;
		border: 1px solid black;
		margin-top: 20px;
		height: 20px;
	}

	.content {
		position: absolute;
		top: 190px;
		left: 20px;
		border: 1px solid rebeccapurple;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		height: 260px;
		width: 90%;
		background-image: url(../../static/zhuzi.webp);
	}

	.view {

		margin: 0% auto;
		border-radius: 20px;
		width: 90%;
		border: 1px solid #e7e6e4;
		height: 200px;
		background-color: #f3f4f6;
		margin-top: 60px;
	}

	.phtot {
		text-align: center;
	}

	.phtot u-avatar {
		position: relative;
		top: -50%;
		left: -50%;
	}

	.aa {
		width: 100%;
		height: 250px;
		background: mediumaquamarine;
		// -webkit-linear-gradient(left, #FFEB67 , #FFDC24);
		position: absolute;
	}

	.bb {
		width: 90%;
		height: 200px;
		background: -webkit-linear-gradient(top, #ffffff, #d3d2d2);
		text-align: center;

		position: absolute;
		left: 15px;
		top: 130px;
		border-radius: 25px;
	}

	/* 评论 */
	.album {
		@include flex;
		align-items: flex-start;

		&__avatar {
			background-color: $u-bg-color;
			padding: 5px;
			border-radius: 3px;
		}

		&__content {
			margin-left: 10px;
			flex: 1;
		}
	}
</style>
